﻿using System;

namespace Gmantis.Zip
{
    public delegate void ZipProgressEventHandler(object sender, ZipProgressEventArgs e);

    public class ZipProgressEventArgs : EventArgs
    {
        // Fields
        private bool _cancel;
        private long _fileLength;
        private string _fileName;
        internal long _position;

        // Methods
        internal ZipProgressEventArgs(string fileName, long fileLength)
        {
            this._fileName = fileName;
            this._fileLength = fileLength;
        }

        // Properties
        public bool Cancel
        {
            get
            {
                return this._cancel;
            }
            set
            {
                this._cancel = value;
            }
        }

        public int FileLength
        {
            get
            {
                if (this._fileLength > 0x7fffffffL)
                {
                    throw new ZipFileException(StringTables.GetString("Length is too large to be represented as an Int32, use LengthLong instead."), this.FileName);
                }
                return (int)this._fileLength;
            }
        }

        public long FileLengthLong
        {
            get
            {
                return this._fileLength;
            }
        }

        public string FileName
        {
            get
            {
                return this._fileName;
            }
        }

        public int Position
        {
            get
            {
                if (this._position > 0x7fffffffL)
                {
                    throw new ZipFileException(StringTables.GetString("Position is too large to be represented as an Int32, use PositionLong instead."), this.FileName);
                }
                return (int)this._position;
            }
        }

        public long PositionLong
        {
            get
            {
                return this._position;
            }
        }
    }
}
